package com.easy.base.api.repository;

import com.easy.base.api.model.entity.UserInfoEntity;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import io.lettuce.core.dynamic.annotation.Param;

/**
 * table => user_info
 */
public interface UserInfoRepository extends JpaRepository<UserInfoEntity, String> {

    @Query(value = "select id, username, '' as password, valid, create_by, create_date, update_by, update_date from user_info", nativeQuery = true)
    public Page<UserInfoEntity> findAllWithoutPassword(Pageable pageable);

    @Query(value = "select id, username, '' as password, valid, create_by, create_date, update_by, update_date from user_info where id= :id", nativeQuery = true)
    public UserInfoEntity findAllByIdWithoutPassword(@Param("id") String id);

    public UserInfoEntity findByUsernameAndPasswordAndValid(String username, String password, boolean valid);
}
